<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent border-hover-style">
    <img class="outline-parent-bg" :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle4Bg.webp'" alt="" />
    <div class="outline">
      <div class="outline-box">
        <div
          class="outline-content"
          :class="
            !props.info.subTitle &&
            !(props.info.audio && props.info.audio.url) &&
            !props.info.remarks &&
            'outlinePadding'
          "
        >
          <div
            class="content-item"
            v-if="props.info.value || (props.info.video && props.info.video.url)"
            :class="
              !props.info.remarks &&
              !props.info.subTitle &&
              !(props.info.audio && props.info.audio.url) &&
              'content-width'
            "
            :style="
              !props.info.remarks &&
              !props.info.subTitle &&
              props.info.audio &&
              props.info.audio.url && { marginLeft: 0 }
            "
          >
            <div class="medium">
              <img
                v-if="props.info.value && !(props.info.video && props.info.video.url)"
                class="outline-cover"
                @click="ImgVisible = true"
                :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
                alt=""
              />
              <videoview @click="audioplay(false)" :info="props.info"></videoview>
            </div>
          </div>
          <div
            class="left-Text"
            v-if="props.info.subTitle || (props.info.audio && props.info.audio.url) || props.info.remarks"
          >
            <div
              v-if="props.info.subTitle || (props.info.audio && props.info.audio.url)"
              class="outline-subTitle"
              :style="!props.info.subTitle && { justifyContent: 'flex-end' }"
            >
              <p>{{ props.info.subTitle }}</p>
              <div
                class="audio-box"
                :class="isPlay && 'audio-rotate'"
                v-if="props.info.audio && props.info.audio.url"
                @click="audioplay(true)"
              >
                <i class="doorIcon">&#xe688;</i>
              </div>
              <audio
                v-if="props.info.audio && props.info.audio.url"
                :src="urls + props.info.audio.url"
                ref="audioRef"
              ></audio>
            </div>
            <div class="line"></div>
            <TextMax
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :infoData="props.info"
              :row="props.info.subTitle || (props.info.audio && props.info.audio.url) ? 7 : 10"
            ></TextMax>
          </div>
        </div>
        <div class="outline-title">
          {{ props.info.text }}
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free2Style4',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 30% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
  overflow: hidden;
}
.outline-parent-bg {
  width: 784px;
  height: 426px;
  // margin-top: 238px;
  margin-top: 77.5px;
  margin-right: 10px;
}
.outline {
  position: absolute;
  // top: 240px;
  top: 78px;
  left: 0;
  z-index: 20;
  width: 784px;
  height: 426px;
  padding-right: 43px;
}
.outline-box {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  overflow: hidden;
}
.outline-title {
  width: 20px;
  font-family: SourceHanSerifCN-Bold;
  font-size: 20px;
  color: #ebf8f7;
  writing-mode: tb-rl;
  letter-spacing: 4px;
  line-height: 20px;
  padding-top: 15px;
}
.outlinePadding {
  padding-right: 16px !important;
  justify-content: center !important;
}
.outline-content {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding-top: 11.5px;
  padding-right: 56px;
  padding-bottom: 4px;
  overflow: hidden;
}
.left-Text {
  width: 100%;
  height: 100%;
  padding-top: 40px;
  margin-left: 40px;
}
.outline-subTitle {
  width: 100%;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  ::v-deep p {
    font-family: SourceHanSerifCN;
    font-size: 18px;
    color: #212326;
    line-height: 28px;
    margin-right: 12px;
    opacity: 63%;
  }
}
.content-item {
  position: relative;
  // flex-shrink: 1;
  width: 296px;
  height: 100%;
  flex-shrink: 0;
}
.content-width {
  width: 100% !important;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
}
.line {
  width: 100%;
  height: 1px;
  background: #212326;
  opacity: 0.6;
  margin-bottom: 25px;
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ffdc76;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0px 2px 4px #0000001a;
  .doorIcon {
    font-size: 24px;
    color: #5b8c87;
  }
}

::v-deep .van-text-ellipsis {
  font-family: SourceHanSerifCN-Medium !important;
  font-size: 16px !important;
  color: rgba(33, 35, 38, 1) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ffdc76 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
::v-deep .t-popup__content {
  background: #5b8c87;
  box-shadow: none;
  padding: 4px 10px;
  font-size: 14px !important;
  line-height: 22px;
  color: #fff;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
}
::v-deep .t-popup__arrow::before {
  background: #5b8c87;
  border: none;
  box-shadow: none !important;
}

.outline-parent-bg2 {
  width: 422px;
  height: 408px;
  margin-top: 138px;
}

.outline2 {
  width: 422px !important;
  height: 408px !important;
  padding: 66px 80px 90px 70px !important;
  position: absolute;
  top: 138px !important;
  left: 0;
  .outline2-title {
    width: 100%;
    font-family: FZYIKS--GB1, FZYIKS--GB1;
    font-size: 30px;
    color: #212326;
    line-height: 34px;
    text-align: center;
    margin-bottom: 16px;
    position: relative;
    box-shadow: 0px 2px 4px #0000001a;
    .audio-box {
      right: -24px;
    }
  }
  .outline2-subTitle {
    width: 100%;
    margin-bottom: 16px;
    font-family: SourceHanSerifCN;
    font-size: 18px;
    color: #212326;
    line-height: 28px;
    text-align: justify;
    opacity: 80%;
    margin-bottom: 16px;
  }
  ::v-deep .van-text-ellipsis__action::before {
    color: #ffdc76 !important;
  }
}
</style>
